import { search } from "../../utils/db";
Page({

data: {
list: [], //菜谱列表
},
async onLoad(e) {
// console.log(e)
let keyword = e.keyword; //接收关键字

//模糊查询
// let result =await db.collection("menu").where({
// name:db.RegExp({
// regexp:keyword,
// options:"i"
// })
// }).get()
// console.log(result)

//用keyword进行模糊查询
let result = await search({ collection: "menu", field: "name", keyword: keyword }).catch(err => {
console.error(err)
})
// console.log(result)
this.setData({
list: result.data
})

},
//跳转详情页
toDetail(e) {
// console.log(e);
var id = e.currentTarget.id; //菜谱id
wx.navigateTo({
url: '/pages/detail/detail?id=' + id,
})
},


})